package com.yy.train.ticket.train.controller;

import com.yy.train.ticket.into.page.LineSectionPage;
import com.yy.train.ticket.train.entity.TtLineSectionEntity;
import com.yy.train.ticket.train.service.TtLineSectionService;
import com.yy.train.ticket.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;



/**
 * 路段
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-10-07 09:09:39
 */
@RestController
@RequestMapping("tt/section")
public class TtLineSectionController {
    @Autowired
    private TtLineSectionService ttLineSectionService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){

        return R.ok();
    }
    @PostMapping("/page")
    public R page(@RequestBody LineSectionPage trainPage){
     /*   LambdaQueryWrapper<TtLineSectionEntity> lambdaQueryWrapper = Wrappers.lambdaQuery();
        Page<TtLineSectionEntity> pages = new Page<TtLineSectionEntity>(trainPage.getPageNum(), trainPage.getPageSize());
        IPage<TtLineSectionEntity> iPage = ttLineSectionService.page(pages, lambdaQueryWrapper);
        return R.ok(iPage);*/
        return  ttLineSectionService.sectionPage(trainPage);
    }

    /**
     * 信息
     */
    @GetMapping("/info/{sectionId}")
    public R info(@PathVariable("sectionId") Long sectionId){
		TtLineSectionEntity ttLineSection = ttLineSectionService.getById(sectionId);

        return R.ok().put("ttLineSection", ttLineSection);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody TtLineSectionEntity ttLineSection){
        return ttLineSectionService.saveLineSection(ttLineSection);


    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody TtLineSectionEntity ttLineSection){
		ttLineSectionService.updateById(ttLineSection);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody List<Long> sectionIds){
		ttLineSectionService.removeByIds(sectionIds);

        return R.ok();
    }

}
